package io.lkt.modules.sys.service.impl;

import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import io.lkt.modules.sys.dao.BBusinessDetailsDao;
import io.lkt.modules.sys.entity.BBusinessDetailsEntity;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BBusinessDictDao;
import io.lkt.modules.sys.entity.BBusinessDictEntity;
import io.lkt.modules.sys.service.BBusinessDictService;

import javax.annotation.Resource;


@Service("bBusinessDictService")
public class BBusinessDictServiceImpl extends ServiceImpl<BBusinessDictDao, BBusinessDictEntity> implements BBusinessDictService {
    @Resource
    BBusinessDictDao bBusinessDictDao;

    @Override
    @DataSource("master")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BBusinessDictEntity> page = this.page(
                new Query<BBusinessDictEntity>().getPage(params),
                new QueryWrapper<BBusinessDictEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @DataSource("master")
    public List<BBusinessDictEntity> queryAll(BBusinessDictEntity bBusinessDict) {
        bBusinessDict.setStatus(1);
        return bBusinessDictDao.queryAll(bBusinessDict);
    }

    @DataSource("master")
    public BBusinessDictEntity getById(Serializable id)
    {
        return (BBusinessDictEntity)((BBusinessDictDao)this.baseMapper).selectById(id);
    }

    @DataSource("master")
    public boolean save(BBusinessDictEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessDictDao)this.baseMapper).insert(entity)));
    }

    @DataSource("master")
    public boolean updateById(BBusinessDictEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessDictDao)this.baseMapper).updateById(entity)));
    }

}
